package interview.huawei.tjt.training.huaweijishitiku;

import java.util.Scanner;

//  密码截取
public class HJ32 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String str = sc.nextLine();
        int res = 0;

        for ( int i = 0; i < str.length(); i ++ ) {
            // ABA型密码
            int len1 = longest(str,i,i);
            // ABBA型密码
            int len2 = longest(str,i,i + 1);

            res = Math.max(res,len1 > len2 ? len1 : len2);
        }

        System.out.println(res);

    }

    public static int longest ( String str, int l, int r ) {
        while ( l >= 0 && r < str.length() && str.charAt(l) == str.charAt(r) ) {
            l --;
            r ++;
        }

        return r - l - 1;

    }
}
